package com.melesta.payment.amazon;

import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import com.amazon.inapp.purchasing.PurchasingManager;
import com.melesta.engine.DatabaseHelper;
import com.melesta.engine.EngineActivity;
import com.melesta.payment.PaymentTransaction;
import com.melesta.payment.interfaces.IListener;
import com.melesta.payment.interfaces.IRequestBuilder;
import com.melesta.payment.interfaces.ISystem;

public class PaymentSystem
  implements ISystem
{
  public static final String SYSTEM_NAME = "amazon";
  private IListener defaultListener;
  private Context mContext;
  private PurchasingObserver mObserver;

  public void buy(Request paramRequest)
  {
    PaymentTransaction localPaymentTransaction = new PaymentTransaction();
    localPaymentTransaction.paymentId = paramRequest.getName();
    localPaymentTransaction.paymentSystem = getName();
    localPaymentTransaction.quantity = 1;
    DatabaseHelper localDatabaseHelper = DatabaseHelper.getHelper(EngineActivity.getInstance());
    localDatabaseHelper.saveTransaction(-1L, localPaymentTransaction);
    String str = PurchasingManager.initiatePurchaseRequest(paramRequest.getSku());
    paramRequest.setId(str);
    localPaymentTransaction.customData = str;
    localDatabaseHelper.saveTransaction(-1L, localPaymentTransaction);
  }

  public Object get(String paramString)
  {
    return null;
  }

  public IListener getDefaultListener()
  {
    return this.defaultListener;
  }

  public String getName()
  {
    return "amazon";
  }

  public IRequestBuilder getRequestBuilder()
  {
    return new RequestBuilder(this);
  }

  public boolean onActivityResult(Context paramContext, int paramInt1, int paramInt2, Intent paramIntent)
  {
    return false;
  }

  public void onCreate(Context paramContext, Handler paramHandler)
  {
    this.mContext = paramContext;
  }

  public void onDestroy(Context paramContext, Handler paramHandler)
  {
    this.mContext = paramContext;
  }

  public void onPause(Context paramContext, Handler paramHandler)
  {
    this.mContext = paramContext;
  }

  public void onResume(Context paramContext, Handler paramHandler)
  {
    this.mContext = paramContext;
    PurchasingManager.initiateGetUserIdRequest();
  }

  public void onStart(Context paramContext, Handler paramHandler)
  {
    this.mContext = paramContext;
    this.mObserver = new PurchasingObserver(paramContext, this);
    PurchasingManager.registerObserver(this.mObserver);
  }

  public void onStop(Context paramContext, Handler paramHandler)
  {
    this.mContext = paramContext;
  }

  public void purchaseProcessed(PaymentTransaction paramPaymentTransaction)
  {
  }

  public ISystem set(String paramString, Object paramObject)
  {
    return this;
  }

  public ISystem setDefaultListener(IListener paramIListener)
  {
    this.defaultListener = paramIListener;
    return this;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.melesta.payment.amazon.PaymentSystem
 * JD-Core Version:    0.6.2
 */